package org.fhm.zdte.common.service.transmission;

import org.fhm.substrate.annotation.Component;
import org.fhm.substrate.service.LoggerHandler;
import org.fhm.substrate.standard.ILogger;
import org.fhm.zdte.common.pojo.Address;
import org.fhm.zdte.common.protocol.AbstractMessageStandard;

import java.util.Objects;
import java.util.function.BiConsumer;

/**
 * The processor of the subcommand package of the connection process.
 *
 * @author 谭波
 * @since 2024/1/31
 */
@Component("CONNECT")
public class ConnectSubPacketDataDeal extends AbstractDataDeal {

    private final ILogger logger = LoggerHandler.getLogger(ConnectSubPacketDataDeal.class);

    @Override
    public void consume(Address n, AbstractMessageStandard e) {
        BiConsumer<Address, AbstractMessageStandard> consumer = dealMapping.get(e.getPacketSubType());
        if (Objects.isNull(consumer))
            logger.warn("message {} has no configure the data processor", e);
        consumer.accept(n, e);
    }
}
